package models

import (
	"github.com/goravel/framework/contracts/database/factory"
	"github.com/goravel/framework/database/orm"
	"github.com/goravel/framework/support/carbon"
	"goravel/database/factories"
)

type User struct {
	orm.Model
	Mobile         string          `gorm:"column:mobile;type:varchar(255);not null;default:''" form:"mobile" json:"mobile"`
	Password       string          `gorm:"column:password;type:varchar(255);not null;default:''" form:"password" json:"password"`
	ExpireTime     carbon.DateTime `gorm:"column:expire_time;type:int(11);not null;default:0" form:"expire_time" json:"expire_time"`
	Configurations []Configuration `form:"configurations" json:"configurations"` // 一个用户有多个配置
	Refillcards    []Refillcard    `form:"refillcards" json:"refillcards"`       // 一个用户有多个充值卡
	orm.SoftDeletes
}

func (*User) Factory() factory.Factory {
	return &factories.UserFactory{}
}

func (u *User) IsAdmin() bool {
	return u.ID == 1
}
